﻿//===============================================================================
// Microsoft patterns & practices
// Composite Application Guidance for Windows Presentation Foundation
//===============================================================================
// Copyright (c) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System.Windows;
using Microsoft.Practices.Unity;
using PJ.Framework.Common;
using PJ.Business.Partner;
using PJ.Business.SalePurchase.Sale;
using PJ.Presentation.SalePurchase.Sale;
using Microsoft.Practices.Composite.Events;
using PJ.Presentation.Partner;
using PJ.Data.Inventory;
using PJ.Data.SalePurchase.Sale;
using PJ.Data.Partner;
using Microsoft.Practices.EnterpriseLibrary.Caching;

namespace PJ.AppPOS
{
    internal class Bootstrapper : Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper
    {
        protected override Microsoft.Practices.Composite.Modularity.IModuleEnumerator GetModuleEnumerator()
        {
            //return new Microsoft.Practices.Composite.Modularity.StaticModuleEnumerator()
            //    .AddModule(typeof(PJ.Presentation.Customer.CustomerModule))
            //    .AddModule(typeof(PJ.Presentation.Inventory.InventoryModule));
            //    .AddModule(typeof(PJ.Presentation.ShoppingCartItem.ShoppingCartItemModule));
            return new Microsoft.Practices.Composite.Modularity.ConfigurationModuleEnumerator(new Microsoft.Practices.Composite.Modularity.ConfigurationStore());
        }

        protected override DependencyObject CreateShell()
        {
            Shell shell = (Shell)Container.Resolve(typeof(Shell));
            shell.Show();

            return shell;
        }
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            InjectionBroker.Instance.InjectionContainer = Container;
            Container.RegisterInstance<ICacheManager>(CacheFactory.GetCacheManager());
            Container.RegisterType<IInventoryItemSalesParamProvider, InventoryItemSalesParamWCFProxyProvider>();
            Container.RegisterType<IInventoryItemProvider, InventoryItemWCFProxyProvider>();

            Container.RegisterType<ICustomerShoppingCartProvider, CustomerShoppingCartPICProvider>();
            Container.RegisterType<ICustomerShoppingCartModel, CustomerShoppingCartModel>();
            Container.RegisterType<ICustomerShoppingCartService, CustomerShoppingCartService>();
            Container.RegisterType<ICustomerShoppingCartView, CustomerShoppingCartGrid>();

            Container.RegisterType<ICustomerShoppingCartItemProvider, CustomerShoppingCartItemPICProvider>();
            Container.RegisterType<ICustomerShoppingCartItemModel, CustomerShoppingCartItemModel>();
            Container.RegisterType<ICustomerShoppingCartItemService, CustomerShoppingCartItemService>();

            Container.RegisterType<ICustomerProvider, CustomerWCFProxyProvider>();
            Container.RegisterType<ICustomerInfoModel, CustomerInfoModel>();
            Container.RegisterType<ICustomerService, CustomerService>();
            Container.RegisterType<ICustomerInfoView, CustomerInfoView>();
        }
    }
}
